import Vue from 'vue'
import VueRouter from 'vue-router'
const BasicLayout = () => import('@/layout/BasicLayout')
const UserLayout = () => import('@/layout/UserLayout')
const MainApp = () => import('@/views/Index')
const MoviePage = () => import('@/views/Movie')
const MovieReview = () => import('@/views/Review')

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: BasicLayout,
    children: [
      {
        path: '',
        component: MainApp,
        meta: {
          title: '电影数据查询',
          module: '/'
        },
      },
      {
        path: '/movie/:id/review/',
        component: MovieReview,
        meta: {
          title: '电影影评查询',
          module: '/'
        }
      },
      {
        path: '/movie/:id',
        component: MoviePage,
        meta: {
          title: '电影数据更新',
          module: '/movie',
        }
      },
      {
        path: '/movie',
        component: MoviePage,
        meta: {
          title: '电影数据新增',
          module: '/movie'
        }
      },

    ]
  },
  {
    path: '/login',
    component: UserLayout,
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach()

export default router
